export default {
	namespaced: true,
	state: {
		addressInfo: JSON.parse(uni.getStorageSync("address") || "{}")
	},
	actions: {},
	mutations: {
		// 更改收货信息的mutation
		updateAddressInfo(state, info) {
			state.addressInfo = info;
			// commit调用userAbout命名空间下的saveAddressToStorage
			this.commit("userAbout/saveAddressToStorage");
		},
		// 持久化存储收货信息
		saveAddressToStorage(state) {
			uni.setStorageSync("address", JSON.stringify(state.addressInfo))
		}
	},
	getters: {
		addressStr(state) {
			if (!state.addressInfo.provinceName) return "";
			return state.addressInfo.provinceName + state.addressInfo.cityName + state.addressInfo.countyName + state.addressInfo.detailInfo
		},		
	}
}